﻿Imports Sy.Data
Public Module MAreaDeal
    Public Function LoadAreaTree() As AreasResponse()
        Return JsonObject.DeserializeSafety(Of AreasResponse())(My.Resources.Areas_Json)
    End Function
    ''获取某一个省市的所有地区
    Function GetAreas(Name As String) As AreasResponse.Cls_city()
        Dim result = LoadAreaTree()
        Dim selectItem = From item As AreasResponse In result Where item.name = Name
        If selectItem.IsNull() OrElse selectItem.Count() = 0 Then Return Null
        Return selectItem.ToArray(0).city
    End Function
    '通过市获取县城
    Function GetThreeArea(ProName As String, CityName As String) As String()
        Dim result = LoadAreaTree()
        Return (From city In
                    ((From item As AreasResponse In result Where item.name = ProName).ToArray(0).city)
                Where city.name = CityName).ToArray(0).area
    End Function
End Module
